// MESSAGE BUC_RESPONSE support class

#pragma once

namespace mavlink {
namespace fppa {
namespace msg {

/**
 * @brief BUC_RESPONSE message
 *
 * Response the params of BUC
 */
struct BUC_RESPONSE : mavlink::Message {
    static constexpr msgid_t MSG_ID = 174;
    static constexpr size_t LENGTH = 30;
    static constexpr size_t MIN_LENGTH = 30;
    static constexpr uint8_t CRC_EXTRA = 58;
    static constexpr auto NAME = "BUC_RESPONSE";


    uint8_t status; /*<  work status. */
    uint8_t cmd; /*<  the cmd of BUC. */
    uint8_t sw; /*<  open or close. */
    float att; /*<  attenuation. */
    uint8_t lo; /*<  lo1 or lo2 or lo3 or lo4. */
    int16_t temp; /*<  temperature. */
    float power; /*<  output power. */
    float gain; /*<  gain. */
    float freq; /*<  frequency(ka.MHz). */
    float res1; /*<  res1. */
    uint32_t res2; /*<  res2. */


    inline std::string get_name(void) const override
    {
            return NAME;
    }

    inline Info get_message_info(void) const override
    {
            return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
    }

    inline std::string to_yaml(void) const override
    {
        std::stringstream ss;

        ss << NAME << ":" << std::endl;
        ss << "  status: " << +status << std::endl;
        ss << "  cmd: " << +cmd << std::endl;
        ss << "  sw: " << +sw << std::endl;
        ss << "  att: " << att << std::endl;
        ss << "  lo: " << +lo << std::endl;
        ss << "  temp: " << temp << std::endl;
        ss << "  power: " << power << std::endl;
        ss << "  gain: " << gain << std::endl;
        ss << "  freq: " << freq << std::endl;
        ss << "  res1: " << res1 << std::endl;
        ss << "  res2: " << res2 << std::endl;

        return ss.str();
    }

    inline void serialize(mavlink::MsgMap &map) const override
    {
        map.reset(MSG_ID, LENGTH);

        map << att;                           // offset: 0
        map << power;                         // offset: 4
        map << gain;                          // offset: 8
        map << freq;                          // offset: 12
        map << res1;                          // offset: 16
        map << res2;                          // offset: 20
        map << temp;                          // offset: 24
        map << status;                        // offset: 26
        map << cmd;                           // offset: 27
        map << sw;                            // offset: 28
        map << lo;                            // offset: 29
    }

    inline void deserialize(mavlink::MsgMap &map) override
    {
        map >> att;                           // offset: 0
        map >> power;                         // offset: 4
        map >> gain;                          // offset: 8
        map >> freq;                          // offset: 12
        map >> res1;                          // offset: 16
        map >> res2;                          // offset: 20
        map >> temp;                          // offset: 24
        map >> status;                        // offset: 26
        map >> cmd;                           // offset: 27
        map >> sw;                            // offset: 28
        map >> lo;                            // offset: 29
    }
};

} // namespace msg
} // namespace fppa
} // namespace mavlink
